<?php
	/**
	 * 
	 * @param unknown_type $pMerBillNo
	 * @return string
	 */
	
	
	function SincerityGoldFreeze($user_id,$platformNo,$pTrdAmt,$deal_id,$from,$post_url,$relate_id,$sys='pc'){
		//$pWebUrl= SITE_DOMAIN.APP_ROOT."/index.php?ctl=collocation&act=response&class_name=Yeepay&class_act=SincerityGoldFreeze&from=".$_REQUEST['from'];//web方式返回
		//$pS2SUrl= SITE_DOMAIN.APP_ROOT."/index.php?ctl=collocation&act=notify&class_name=Yeepay&class_act=SincerityGoldFreeze&from=".$_REQUEST['from'];//s2s方式返回		
		$user = array();
		$user = $GLOBALS['db']->getRow("select * from ".DB_PREFIX."user where id = ".$user_id);
		
		
		
		$unfree_month = app_conf("MORTGAGE_MONEY_UNFREEZE")?app_conf("MORTGAGE_MONEY_UNFREEZE"):12;
		//$data['expired'] =to_date(TIME_UTC+3600*12+3600*24*30*$unfree_month,"Y-m-d H:i:s"); //到期自动解冻时间			
		//$strxml = SincerityGoldFreezeXml($data,$pWebUrl,$pS2SUrl);
		//amt + "|" + cust_no+"|"+ mchnt_cd + "|" + mchnt_txn_ssn+"|"+ rem
		$data =$Sign_data = array();
		$data['requestNo'] = $requestNo;//请求流水号
		$data['platformUserNo'] = $user_id;//
		$data['deal_id']=$deal_id;
		$data['type']=2;
		$data['relate_id']=$relate_id;
		
		$data['platformNo'] = $Sign_data['mchnt_cd'] = $platformNo;// 商户编号
		$data['mchnt_txn_ssn'] =$Sign_data['mchnt_txn_ssn'] = $user['id'].time();
		$data['cust_no'] = $Sign_data['cust_no'] =$user['mobile'];
		$data['amount'] = $pTrdAmt ;
		
		$Sign_data['ver'] = "0.44";
		$Sign_data['amt'] = $pTrdAmt*100;// 记录投标金额
		$Sign_data['rem'] ='冻结';
		
		/* 请求参数 */
		ksort($Sign_data);
		foreach($Sign_data as $k => $v){
			if($k == 'ver'){
				$Sign_old .=$v;
				$Sign_old_a .=$k;
			}else{
				$Sign_old .=$v."|";
				$Sign_old_a .=$k."+|+";
			}
		}
		/* 签名数据 */
		$pSign=rsaSign($Sign_old,PRIVATE_KEY_PATH);
		/* 调用账户查询服务 */
		$req = http_build_query($Sign_data)."&signature=".urlencode($pSign);
		
		$fuioupay_log = array();
		$fuioupay_log['code'] = 'FREEZE';
		$fuioupay_log['create_date'] = to_date(TIME_UTC,'Y-m-d H:i:s');
		$fuioupay_log['strxml'] = $req;
		$GLOBALS['db']->autoExecute(DB_PREFIX."fuioupay_log",$fuioupay_log);
		$requestNo = $GLOBALS['db']->insert_id();
		
		$options = array(
			CURLOPT_POST => TRUE,
			CURLOPT_RETURNTRANSFER => TRUE,
			CURLOPT_SSL_VERIFYPEER=>0,
			CURLOPT_SSL_VERIFYHOST=>0,
			CURLOPT_POSTFIELDS =>$req,
		
		); 
	    $ch = curl_init($post_url); 
	    curl_setopt_array($ch,$options); 
	   	$resultStr = curl_exec($ch);
	    curl_close($ch);
		if (empty($resultStr)){
				//$err_count ++ ;
			}else{
					require_once APP_ROOT_PATH.'system/collocation/fuioupay/xml.php';
					$str3ParaInfo = @XML_unserialize($resultStr);
 					$str3Req = $str3ParaInfo['ap']['plain'];
					$result = array();
					$result['resp_code'] = $str3Req["resp_code"];
					$result['mchnt_cd'] = $str3Req["mchnt_cd"];
					$result['mchnt_txn_ssn'] = $str3Req["mchnt_txn_ssn"];
					$result['contract_no'] =  $str3Req['contract_no'];
					$result['signature'] =  $str3ParaInfo['ap']['signature'];
					//$result['rsaXML'] = substr($resultStr,42,169);
 					if($str3Req["resp_code"] =='0000')
					{
						
						//code
						//$code = fuiou_code();
						//$str3Req['description'] = $code[$str3Req["code"]];
						//操作成功					
						$data['code'] = $str3Req["resp_code"];//1 成功 0 失败 2 xml参数格式错误 3 签名验证失败 101 引用了不存在的对象（例如错误的订单号） 102 业务状态不正确 103 由于业务限制导致业务不能执行 104 实名认证失败						
						$data['is_callback'] = 1;
						$data['status'] = 1;
						$data['pay_type']=0;
						$data['create_time']=TIME_UTC;
						if (isset($str3Req['description']))
							$data['description'] = $str3Req["description"];

						$GLOBALS['db']->autoExecute(DB_PREFIX."money_freeze",$data,'INSERT');
						$id = $GLOBALS['db']->insert_id();
						$from = 'web';
						$results['status'] = 0;
						if($from=='web'){
				 			//showIpsInfo('诚意金支付成功',url("deal#estate_show",array("id"=>$deal_id)));
				 			$results['status'] = 1;
				 			$results['info'] = '诚意金支付成功';
				 			$results['url'] = url("deal#estate_show",array("id"=>$deal_id));
				 			return $results;
				 		}elseif($from=='wap'){
				 			//showIpsInfo('诚意金支付成功',url_wap("deal#index",array("id"=>$deal_id)));
				 			$results['status'] = 1;
				 			$results['info'] = '诚意金支付成功';
				 			$results['url'] = url_wap("deal#estate_show",array("id"=>$deal_id));
				 			return $results;
				 		}elseif($from=='app'){
				 			echo "诚意金支付成功<br />请点左上角<b>返回</b>按钮";
				 		}
					}else{
						if($from=='web'){
				 			showIpsInfo($str3Req["description"],url("deal#estate_show",array("id"=>$deal_id)));	
				 		}elseif($from=='wap'){
				 			showIpsInfo($str3Req["description"],url_wap("deal#index",array("id"=>$deal_id)));	
				 		}elseif($from=='app'){
				 			echo $str3Req["description"]."<br />请点左上角<b>返回</b>按钮";
				 		}
						
					}
					
			}
	
	}
	
?>